package cn.iocoder.yudao.module.dr.dal.mysql.collectionlinkaddress;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.dr.controller.admin.collectionlinkaddress.vo.*;
import cn.iocoder.yudao.module.dr.controller.admin.report.vo.index.DeptUseDataRespVO;
import cn.iocoder.yudao.module.dr.controller.admin.report.vo.index.FileTypeDataRespVO;
import cn.iocoder.yudao.module.dr.controller.admin.report.vo.index.SourceTypeDataRespVO;
import cn.iocoder.yudao.module.dr.controller.admin.report.vo.index.VisitDataRespVO;
import cn.iocoder.yudao.module.dr.dal.dataobject.collectionlinkaddress.CollectionLinkAddressDO;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 藏品模型链接地址 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface CollectionLinkAddressMapper extends BaseMapperX<CollectionLinkAddressDO> {

    default LambdaQueryWrapperX<CollectionLinkAddressDO> getQuery(CollectionLinkAddressPageReqVO reqVO) {
        return  new LambdaQueryWrapperX<CollectionLinkAddressDO>()
                .betweenIfPresent(CollectionLinkAddressDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(CollectionLinkAddressDO::getCollectionId, reqVO.getCollectionId())
                .eqIfPresent(CollectionLinkAddressDO::getType, reqVO.getType())
                .likeIfPresent(CollectionLinkAddressDO::getFileName, reqVO.getFileName())
                .eqIfPresent(CollectionLinkAddressDO::getLinkAddress, reqVO.getLinkAddress()) ;
    }

    default PageResult<CollectionLinkAddressDO> selectPage(CollectionLinkAddressPageReqVO reqVO) {
        return selectPage(reqVO,getQuery(reqVO)
                .orderByDesc(CollectionLinkAddressDO::getId));
    }

    default List<CollectionLinkAddressDO> selectList(CollectionLinkAddressPageReqVO reqVO) {
        return selectList(getQuery(reqVO).orderByDesc(CollectionLinkAddressDO::getId));
    }

    default List<CollectionLinkAddressDO> selectListByCollectionId(Long collectionId,String bizType) {
        LambdaQueryWrapperX<CollectionLinkAddressDO> query = new LambdaQueryWrapperX<CollectionLinkAddressDO>();
        query.eq(CollectionLinkAddressDO::getCollectionId, collectionId);
        query.eq(CollectionLinkAddressDO::getBizType, bizType);
        return selectList(query);
    }

    default int deleteByCollectionId(Long collectionId) {
        return delete(CollectionLinkAddressDO::getCollectionId, collectionId);
    }

    default int deleteByCollectionIdAndBizType(Long collectionId, String bizType){
        LambdaQueryWrapperX<CollectionLinkAddressDO> delete = new LambdaQueryWrapperX<>();
        delete.eq(CollectionLinkAddressDO::getCollectionId, collectionId);
        delete.eq(CollectionLinkAddressDO::getBizType, bizType);
        return delete(delete);
    }

    @InterceptorIgnore(tenantLine = "true", dataPermission = "false")
    List<SourceTypeDataRespVO> countByLevel();

    @InterceptorIgnore(tenantLine = "true", dataPermission = "false")
    List<FileTypeDataRespVO> countBySource();

    @InterceptorIgnore(tenantLine = "true", dataPermission = "false")
    List<DeptUseDataRespVO> countByDegree();

    @InterceptorIgnore(tenantLine = "true", dataPermission = "false")
    List<VisitDataRespVO> countByCategory();

    @InterceptorIgnore(tenantLine = "true", dataPermission = "false")
    List<SourceTypeDataRespVO> countByImage();

    @InterceptorIgnore(tenantLine = "true", dataPermission = "false")
    List<FileTypeDataRespVO> countBy3d();

    @InterceptorIgnore(tenantLine = "true", dataPermission = "false")
    List<DeptUseDataRespVO> countByBizType();


}